#!/bin/bash
function start() {
  echo "[INFO] Starting zooKeeper"
  /bin/bash /opt/software/kafka_2.13-3.1.0/bin/zookeeper-server-start.sh /opt/software/kafka_2.13-3.1.0/config/zookeeper.properties >/dev/null 2>&1 &
  echo "[INFO] Starting kafka"
  /bin/bash /opt/software/kafka_2.13-3.1.0/bin/kafka-server-start.sh /opt/software/kafka_2.13-3.1.0/config/server.properties >/dev/null 2>&1 &
}

function stop() {
  echo "[INFO] Stopping kafka"
  /bin/bash /opt/software/kafka_2.13-3.1.0/bin/kafka-server-stop.sh >/dev/null 2>&1 &
  echo "[INFO] Stopping zooKeeper"
  /bin/bash /opt/software/kafka_2.13-3.1.0/bin/zookeeper-server-stop.sh >/dev/null 2>&1 &
}

function main() {
  if [ "$1" == "start" ]; then
    start
  elif [ "$1" == "stop" ]; then
    stop
  fi
}

main "$@"
